@extends('default.layouts.companyPublic')

@section('title', '企业账户中心')
@section('headcss')
    @parent
    <link rel="stylesheet" type="text/css" href="{{asset('/default/css/company/welcome.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('/vendor/webuploader/dist/webuploader_img.css')}}">
@endsection

@section('rightcon')
    <div class="right">
        <div class="rightContain">
            <div class="rightTop">
                <div class="rightHead">
                    <div class="logoPic">
                        <div class="pic"><span id="picker"><img
                                        src="@if(!empty($companyBasic->logo)){{asset('/upload/companylogo/'.$companyBasic->logo)}}@else{{asset('/default/images/company/nulllogo.gif')}}@endif"
                                        width="100" height="100"></span></div>
                        <div class="text">
                            <div class="progress w50">50%</div>
                        </div>
                    </div>

                    <div class="message">
                        <div class="detail">
                            <dl>
                                <dt><b>{{$companyBasic->company_name}}</b></dt>
                                <dd>{{$companyBasic->contacts}} @if(!empty($companyBasic->phone)){{$companyBasic->phone}}@else{{$companyBasic->mobile}}@endif</dd>
                                <dd> @if(!empty($companyBasic->email)){{$companyBasic->email}}@else 未填写Email @endif</dd>
                            </dl>
                            <ul>
                                @if($companyBasic->cert_status == '1')
                                    <li class="identification">
                                        <a href="{{url('/company/license_sub')}}"><i class="verified"></i>已认证</a>
                                    </li>
                                @else
                                    <li class="identification">
                                        <a href="{{url('/company/license_sub')}}"><i class="no_verified"></i>未认证</a>
                                    </li>
                                @endif
                                @if(!empty($userInfo->wechatunionid) || !empty($userInfo->wechatmpopenid))
                                    <li class="wx"><i class="bind"></i><a href="{{url('/company/set_account')}}">已绑定</a>
                                    </li>
                                @else
                                    <li class="wx"><i class="no_bind"></i><a
                                                href="{{url('/company/set_account')}}">未绑定</a></li>
                                @endif
                                <li class="recruit"><i></i><a onclick="micro('{{$companyBasic->id }}')">微招聘</a></li>
                            </ul>
                        </div>

                        <div class="edit">
                            <div class="editMessage"><i></i><a href="{{url('/company/basic_info')}}"><span
                                            class="editText">编辑资料</span></a></div>
                            @if($endtime[0]<=0)
                                <span class="vip">普通会员</span>
                                <a class="pay" href="{{ route("myOrder.index") }}"><i></i><span
                                            class="paycheck">升级VIP</span> </a>
                            @elseif($endtime[0]>30 && $endtime[1]=='天')
                                <span class="vip">尊贵的VIP</span>
                                <a class="look" href="{{url('/company/member_records')}}"><span
                                            class="paycheck">查看服务</span> </a>
                            @else
                                <span class="vip">VIP还剩{{$endtime[0]}}{{$endtime[1]}}</span>
                                <a class="pay" href="{{url('/company/member_records')}}"><i></i><span class="paycheck">VIP续费</span>
                                </a>
                            @endif
                        </div>
                    </div>

                </div>

                <div class="headPic"><img src="{{ $CrmService->img  }}" width="124" height="142"></div>
                <div class="service">
                    <ul>
                        <li class="yours"><b>您的客服 {{ $CrmService->worker_name }}</b></li>
                        <li class="telphone"><i></i><span class="tel">{{ substr($CrmService->mobile,0,11) }}</span></li>
                        <li class="tencent"><i></i><span class="qq">{{ substr($CrmService->qq,0,12) }}</span></li>
                        <li class="weixin"><i></i><span class="wx"
                                                        id="wx">{{ str_limit($CrmService->weichat,18) }}</span></li>
                        <li class="serviceText"
                            id="serviceText">{{ empty($CrmService->enounce) ? '您的满意是我不懈的追求！' : str_limit($CrmService->enounce,22) }}</li>
                    </ul>
                </div>

            </div>
            <div class="rightMiddle">
                <a class="rectangle" href="{{url('/company/resume_message')}}">
                    <dl>
                        <dt class="receiveNum">{{$resumeSendCount}}</dt>
                        <dd class="receiveResume">三个月收到简历</dd>
                    </dl>
                </a>
                <a class="rectangle" onclick="refreshWwindow(dhtml)">
                    <dl>
                        <dt class="reflashPic"><i></i></dt>
                        <dd class="reflashJob">刷新职位</dd>
                    </dl>
                </a>
                <a class="rectangle" href="{{url('/company/jobpublish')}}">
                    <dl>
                        <dt class="postPic"><i></i></dt>
                        <dd class="postOffice">新增职位</dd>
                    </dl>
                </a>
                <div class="integral">
                    <div class="integralLeft">
                        <div class="totalIntegral"><span
                                    class="integralNum">积分：{{$integralNumber}}</span>
                            <a onclick="refreshWwindow(dhtml)">职位加急</a></div>
                        <div class="use"><span class="useIntegral">积分用处：</span><a onclick="smartRefresh()">智能刷新</a>
                        </div>
                        <i></i>
                    </div>
                    <div class="integralRight">
                        @if(count($vipNews)>0)
                            <ul>
                                @foreach($vipNews as $v)
                                    <li><a target="_blank"
                                           href="{{url('/newsinfo_'.$v->id.'.html')}}">{{str_limit($v->title,22)}}</a>
                                    </li>
                                @endforeach
                            </ul>
                        @endif
                    </div>
                </div>
            </div>

            <div class="rightBottom">
                <div class="recommend">给您推荐的人才</div>
                @if(count($companyJob)>0)
                    <div class="poslist">
                        @foreach($companyJob as $v)
                            <dl>
                                <dt><a href="{{url('/jobinfo_'.idEncryption($v->id).'.html')}}"
                                       target="_blank">{{str_limit($v->job_title,20)}}</a>{{$v->recruiting_num}}名
                                </dt>
                                <dd>{{$v->salary_above}}元~{{$v->salary_below}}元/月<a
                                            href="{{url('/company/intelligent_search?id='.$v->id)}}" target="_blank">查看配置人才</a>
                                </dd>
                            </dl>
                        @endforeach
                    </div>
                @else
                    <div class="nojobtext">
                        <P class="nojob">您还没有发布的职位</P>
                        <P class="useful">发布职位，320万人才给您投递简历</P>
                        <a href="{{url('/company/jobpublish')}}">立即发布职位</a>
                    </div>

                @endif
            </div>
        </div>
    </div>
@endsection
@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/vendor/webuploader/dist/webuploader.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/company/job_list.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.form.js')}}"></script>

    <script type="text/javascript">
        $("#leftnav_account").addClass("active");
        var uploader = WebUploader.create({

            auto: true,
            duplicate: true,
            multiple: false,

            // swf文件路径
            swf: BASE_URL + 'vendor/webuploader/dist/Uploader.swf',

            // 文件接收服务端。
            server: "{{asset('/company/logoupload')}}?_token={{csrf_token()}}",

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: {
                id: '#picker',
                name: "file", //这个地方 name 没什么用，虽然打开调试器，input的名字确实改过来了。但是提交到后台取不到文件。如果想自定义file的name属性，还是要和fileVal 配合使用。
                //label: '点击选择图片',
                multiple: false //默认为true，就是可以多选
            },
            compress: {
                width: 200,
                height: 200,
                // 图片质量，只有type为`image/jpeg`的时候才有效。
                //quality: 100,
                // 是否允许放大，如果想要生成小图的时候不失真，此选项应该设置为false.
                allowMagnify: true,
                // 是否允许裁剪。
                crop: true,
                allowMagnify: true,
                compressSize: 0,
                noCompressIfLarger: false
            },

            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: '.gif,.jpg,.jpeg,.bmp,.png'
            },
            fileSingleSizeLimit: 2000 * 1024
        });
        //上传文件出错时
        uploader.on('error', function(file){
            if(file == 'F_EXCEED_SIZE'){
                layer.msg('文件大小不能超过2M！', {time: 1200});
            }
            if(file == 'F_DUPLICATE'){
                layer.msg('此文件已经存在队列当中，不能重复上传！', {time: 1200});
            }
            if(file == 'Q_EXCEED_NUM_LIMIT'){
                layer.msg('你已经上传了文件！', {time: 1200});
            }
            if(file == 'Q_TYPE_DENIED'){
                layer.msg('文件类型不匹配，请重新上传！', {time: 1200});
            }
        });
        uploader.on('uploadSuccess', function(file, response){
            if(response.status == 200){
                //            $("#picker img").attr("src",response.url);
                //            layer.msg(response.info);
                //            alert(333333333);
                location = '/company/welcome';

            }else{
                layer.msg(response.info);
            }
            //alert(response.url);
            ///console.log(response)
        });

        var dhtml = '';
        @if(count($companyJob)>0)
                dhtml += '<div class="jobrefresh"><div class="count">目前发布中的职位共<b>{{count($companyJob)}}</b>个</div>';
        dhtml += '        <form action="" id="thisForm" name="thisForm" method="post">';
        dhtml += '        {!! csrf_field() !!}';
        dhtml += '       <ul class="one">';
        dhtml += '        <li class="p1"></li>';
        dhtml += '        <li class="p2">职位</li>';
        dhtml += '        <li>月薪</li>';
        dhtml += '        <li>浏览量</li>';
        dhtml += '        <li class="p9">加急</li>';
        dhtml += '        </ul>';
        dhtml += '        <div class="listdiv">';
        @foreach($companyJob as $v)
                dhtml += '        <ul class="list">';
        dhtml += '        <li class="p1"><input name="selected_id[]" class="checkboxs" value="{{$v->id}}" checked="checked" type="checkbox"/></li>';
        dhtml += '        <li class="p2" id="postitle_{{$v->id}}"><a href="{{url('/jobinfo_'.idEncryption($v->id).'.html')}}" target="_blank">{{str_limit($v->job_title,20)}}</a>@if($v->iurgent==1)<i class="iurgent"></i>@endif</li>';
        dhtml += '        <li>@if($v->salary_above){{$v->salary_above}}~{{$v->salary_below}}@else面议@endif</li>';
        dhtml += '        <li>{{$v->pageviews}}</li>';
        dhtml += '        <li class="p9"><a class="urgent @if($v->iurgent==1) urgent2 @endif" id="urgentnav" onclick="ajaxUrgent(this,\'{{url('/company/urgent?id='.$v->id)}}\',{{$v->id}})">加急</a></li>';
        dhtml += '        </ul>';
        @endforeach
                dhtml += '        </div>';
        dhtml += '        <ul class="refresh_nav">';
        dhtml += '        <li style="width:60px;">';
        dhtml += '        <input name="selectall" id="selectall" class="checkboxs" value="1" type="checkbox" checked="checked"  onclick="CheckAll(this)"/>';
        dhtml += '        <label for="selectall">全选</label>';
        dhtml += '        </li>';
        dhtml += '        <li class="p500">';
        dhtml += '        <a class="pborder" onclick="ajaxRefresh(\'{{url('company/refresh')}}\')">刷新职位</a>';
        dhtml += '        <a class="pborder" href="{{url('/company/jobpublish')}}"><i></i>新增职位</a>';
        dhtml += '       </li>';
        dhtml += '       </ul>';
        dhtml += '       </form>';
        @else
                dhtml += '        <div class="jobrefresh"><div class="nojobtext">';
        dhtml += '        <P class="nojob">您还没有发布的职位</P><P class="useful">发布职位，320万人才给您投递简历</P>';
        dhtml += '        <a href="{{url('/company/jobpublish')}}">立即发布职位</a>';
        dhtml += '        </div></div>';
        @endif
                dhtml += '        </div>';

        var refreshOpen = '';
        function refreshWwindow(html){
            refreshOpen = layer.open({
                type: 1,
                title: "刷新职位",
                skin: 'layui-layer-rim', //加上边框
                area: ['800px', '640px'], //宽高
                content: html
            });
        }
        {{--@if($refreshtip=='yes')--}}
        {{--refreshWwindow(dhtml);--}}
        {{--@endif--}}
        //微信
        $("#wx").mouseover(function(){
            var wxTip = layer.tips('{{ $CrmService->weichat }}', '#wx', {tips: 3});
            $("#wx").mouseout(function(){
                layer.close(wxTip);
            });
        });
        //客服个人宣言提醒
        $("#serviceText").mouseover(function(){
            var serviceTextTip = layer.tips('{{ $CrmService->enounce }}', '#serviceText', {tips: 3});
            $("#serviceText").mouseout(function(){
                layer.close(serviceTextTip);
            });
        });

        @if(empty(session('company_api')))
            @if(empty($userInfo->api_token) && ( !empty(Site::get('appCompanyHasIOS')) || !empty(Site::get('appCompanyHasAndroid')) ) )
                //手机app下载
                var apphtml = '';
                apphtml += '<div class="syncApp">';
                apphtml += '<div class="syncMobile"><h2>您还未同步移动端，扫一扫下载APP</h2></div>';
                apphtml += '<div class="content">';
                apphtml += '<div class="sright">';
                apphtml += '<p class="one">在线<b>聊</b>工作，实时<b>收</b>简历</p>';
                apphtml += '<p class="two">一个APP全搞定</p>';
                apphtml += '<ul>';
                apphtml += '<li>在线与应聘者聊工作，和冰冷的简历说再见</li>';
                apphtml += '<li>实时查收应聘简历、通过/拒绝免试申请</li>';
                apphtml += '</ul>';
                apphtml += '<div class="down">';
                apphtml += '<img src="{{asset('default/images/logo/spread_comp.png')}}">';
                apphtml += '<span class="sao">扫一扫下载APP</span>';
                apphtml += '</div>';
                apphtml += '</div>';
                apphtml += '</div>';
                apphtml += '</div>';
                {{--apphtml += '<div style=""><img src="{{asset('default/images/logo/spread_comp.png')}}"></div><div style="text-align: center">扫一扫分享到朋友圈</div>';--}}
                layer.open({
                    type: 1,
                    title: "",
                    skin: 'layui-layer-rim', //加上边框
                    area: ['800px', '576px'], //宽高
                    content: apphtml,
                    end: function(){
                        $.post("/company/set_api_session", { '_token': "{{csrf_token()}}"}, function (data) {});
                        @if($refreshtip=='yes')
                            refreshWwindow(dhtml);
                        @endif
                    }
                });
            @else
                @if($refreshtip=='yes')
                    refreshWwindow(dhtml);
                @endif
            @endif
        @endif


            /**
         * 智能刷新
         */
        var sign = true;
        function smartRefresh(){
                    @if(count($companyJob)>0)
            var str = '';
            str += '<div class="smart_refresh"><div class="count">' +
                    '@if(!empty($uptime)) <span class="expiredate">你当前的时间智能刷新到期时间是：<b style="color:#ff4400">{{$uptime}}</b></span> @else <span  class="expiredate">你还没设置当前的智能刷新时间</span> @endif' +
                    '<span class="have">您当前拥有<b>{{$integralNumber}}</b>个积分</span>' +
                    '<span class="recharge"><a href="{{url('company/my_order')}}">马上充值</a></span></div>';
            str += '<form action="" id="intelligentForm" name="intelligentForm" method="post">';
            str += '<input name="com_uid"  type="hidden" id="com_uid"  value="{{$userInfo->uid}}">';
            str += '{!! csrf_field() !!}';
            str += '<ul class="one">';
            str += '<li>套餐资源</li>';
            str += '<li>积分价格</li>';
            str += '</ul>';
            str += '<ul>';
            str += '<li><input name="days" class="radio" type="radio" id="radio1" checked value="7"><label for="radio1">刷新21次（7天）</label></li>';
            str += '<li><b>105</b>积分(5积分/次)</li>';
            str += '</ul>';
            str += '<ul>';
            str += '<li><input name="days" class="radio" type="radio" id="radio2" value="3"><label for="radio2">刷新9次（3天）</label></li>';
            str += '<li><b>45</b>积分(5积分/次)</li>';
            str += '</ul>';
            str += '<ul>';
            str += '<li><input name="days" class="radio" type="radio" id="radio3" value="15"><label for="radio3">刷新45次（15天）</label></li>';
            str += '<li><b>225</b>积分(5积分/次)</li>';
            str += '</ul>';
            str += '</form>';
            str += '</div>';

            layer.confirm("刷新职位", {
                type: 1,
                btn: ['确定', '取消'], //按钮
                title: "智能刷新",
                area: ['540px', '360px'], //宽高,
                content: str
            }, function(){
                {{--@if($userInfo->viptime>date('Y-m-d H:i:s')){{$userInfo->vip_integral}}@else{{$userInfo->integral}}@endif--}}

                {{--var days = $("#intelligentForm").find("input[type='radio']:checked").val();--}}
                {{--var number = (days*3*5);//需要积分的数量--}}
                layer.confirm("您真的要设置职位智能刷新吗?自动刷新将消耗5个积分一次", {
                    btn: ['确定', '取消'], //按钮
                    title: "智能刷新"
                }, function(){
                    var queryString = $('#intelligentForm').formSerialize();
                    if(sign){
                        sign = false;
                        $.ajax({
                            type: "post",
                            url: '/company/intelligent',
                            data: queryString,
                            dataType: "json",
                            success: function(data){
                                if(data.status == 1){
                                    layer.msg(data.msg);
                                    sign = true;
                                }else{
                                    layer.msg(data.msg);
                                    sign = true;
                                    location = '/company/welcome';
                                }
                            }
                        });
                    }
                });
            });
            @else
                layer.msg('请先添加职位，在智能刷新', {time: 1500});
            @endif
        }

        /**
         * 微招聘
         * param id
         */
        function micro(id){
            layer.open({
                type: 1,
                title: '微招聘',
                skin: 'layer-toshare',
                area: ['240px', '295px'],
                resize: false,
                move: false,
                btn: false,
                content: '<div style=""><img src="{{asset('company/micro?com_id=')}}' + id + '"></div><div style="text-align: center">扫一扫分享到朋友圈</div>'
            });
        }
    </script>
@endsection